package com.alinesno.cloud.initializr.starter.gateway.rest;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alinesno.cloud.common.core.constants.SpringInstanceScope;
import com.alinesno.cloud.common.facade.pageable.DatatablesPageBean;
import com.alinesno.cloud.common.facade.response.AjaxResult;
import com.alinesno.cloud.initializr.starter.entity.ProjectInfoEntity;
import com.alinesno.cloud.initializr.starter.service.IBuildProjectInfoService;
import com.alinesno.cloud.rest.gateway.adapter.page.TableDataInfo;
import com.alinesno.cloud.rest.gateway.adapter.plugins.TranslateCode;
import com.alinesno.cloud.rest.gateway.adapter.rest.BaseRestAdapter;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
/**
 * 【请填写功能名称】Controller
 *
 * @author alinesno
 * @date 2021-06-05
 */
@RestController
@Scope(SpringInstanceScope.PROTOTYPE)
@RequestMapping("com/alinesno/cloud/business/buildProjectInfo" )
public class BuildProjectInfoRest extends BaseRestAdapter<ProjectInfoEntity , IBuildProjectInfoService> {

	//日志记录
    private static final Logger log = LoggerFactory.getLogger(BuildProjectInfoRest.class);
    
    @Autowired
    private IBuildProjectInfoService buildProjectInfoService;

    @TranslateCode
    @ResponseBody
    @PostMapping("/datatables")
    public TableDataInfo datatables(HttpServletRequest request , Model model ,  DatatablesPageBean page){
        log.debug("page = {}" , ToStringBuilder.reflectionToString(page));
		return this.toPage(model, this.getFeign() , page) ;
    }
    
  
    /**
     * 获取我的应用
     * @return
     */
    @SuppressWarnings("unused")
	@GetMapping("/initMyApplication")
    public AjaxResult initMyApplication() {
   
    	QueryWrapper<ProjectInfoEntity> queryWrapper = new QueryWrapper<>() ; 
    	queryWrapper.isNotNull("project_name") ;
    	List<ProjectInfoEntity> list = buildProjectInfoService.list(queryWrapper) ; 
    	
//    	List<ProjectVo> voList = converDto(list , ProjectVo.class) ; // new ArrayList<ProjectVo>() ;
    	
    	return AjaxResult.success(new ArrayList<>()) ;
    }
  
    
    /**
     * 获取发布结果
     */

    @Override
    public IBuildProjectInfoService getFeign() {
        return this.buildProjectInfoService;
    }
    

}
